package cn.com.oidreams.aliyun.robot.entity;

import cn.com.oidreams.aliyun.robot.enums.DingTalkEnum;
import cn.com.oidreams.common.annotations.Required;
import lombok.Data;

/***
 ** @category 请用一句话描述这个类的用途
 ** @author qing.yunhui
 ** @email: qingyh@glodon.com
 ** @createTime: 2021-11-24 15:52
 **/
@Data
public class MarkDownMsgRequest extends BaseRequest{

    @Required(errorMsg = "markdown不能为空",remark="markdown",classParse = true)
    private Markdown markdown;
    // --------------- 非必填 ---------------
    private At at;
    // --------------- 构建函数 ---------------
    public MarkDownMsgRequest(Markdown markdown, At at,String secret) {
        super.setMsgtype(DingTalkEnum.MSG_TYPE.MARKDOWN.getCode());
        this.markdown = markdown;
        this.at = at;
        super.setTimestamp(System.currentTimeMillis());
        super.setSecret(secret);
    }
    public MarkDownMsgRequest(Markdown markdown,String secret){
        this(markdown,null,secret);
    }
    // -------------------------->> 内部类 <<--------------------------
    @Data
    public static class Markdown{
        @Required(errorMsg = "首屏会话透出的展示内容不能为空!",remark = "首屏会话透出的展示内容",classParse = false)
        private String title;
        @Required(errorMsg = "消息不能为空!",remark = "markdown格式的消息",classParse = false)
        private String text;
        public Markdown(String title, String text) {
            this.title = title;
            this.text = text;
        }
    }
    @Data
    public static class At{
        /**
         * <p>被@人的手机号(注意:在text内容里要有@人的手机号，只有在群内的成员才可被@，非群内成员手机号会被脱敏)</p>
         * */
       private String[] atMobiles;
       /**
        * <p>被@人的用户userid(注意 在content里添加@人的userid)</p>
        * */
       private String[] atUserIds;
       /**
        * <p>是否@所有人</p>
        * */
       private boolean isAtAll;
       public At(String[] atMobiles, String[] atUserIds, boolean isAtAll) {
            this.atMobiles = atMobiles;
            this.atUserIds = atUserIds;
            this.isAtAll = isAtAll;
       }
    }
}
